package com.atguigu.spzx.user.controller;

import com.atguigu.spzx.model.entity.user.Region;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import com.atguigu.spzx.user.service.UserRegionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author syh
 * @create 2023-09-04 9:52
 */
@Tag(name = "地区信息模块")
@RestController
@RequestMapping("/api/user/region")
public class UserRegionController {
    @Resource
    UserRegionService userRegionService;
    @GetMapping("/findByParentCode/{parentId}")
    @Operation(summary = "根据父Id查询下一级信息")
    public Result<Region> findByParentCode(@PathVariable("parentId")Long parentId){
           List<Region> regionList = userRegionService.findByParentCode(parentId);

        return Result.build(regionList, ResultCodeEnum.SUCCESS);
    }

}
